package com.player.entity;

import javax.persistence.Id;
import javax.persistence.Transient;

import com.googlecode.objectify.Key;
import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Indexed;
import com.googlecode.objectify.annotation.Unindexed;

// @Cached(expirationSeconds = 24 * 60 * 60)
@Entity
public class Ranking {

	// FIXME index/unindex (ifclauses... ??)

	@Id
	Long id;

	// @Parent
	@Indexed
	Key<Player> playerKey;

	@Transient
	Player player;

	@Transient
	long rank;

	@Indexed
	String rankinglist;

	@Unindexed
	long points;

	@Unindexed
	String rankingTrend;

	public Ranking() {
	}

	public Ranking(Long playerId, RankinglistType rankinglistType) {
		super();
		this.playerKey = new Key<Player>(Player.class, playerId);
		this.rankinglist = rankinglistType.name();
		this.rank = -1l;
		this.points = 0l;
		this.rankingTrend = RankingTrendType.STEADY.name();
	}

	public Long getId() {
		return id;
	}

	public Key<Player> getPlayerKey() {
		return playerKey;
	}

	public Player getPlayer() {
		return player;
	}

	public void setPlayer(Player player) {
		this.player = player;
	}

	public long getRank() {
		return rank;
	}

	public void setRank(long rank) {
		this.rank = rank;
	}

	public String getRankinglist() {
		return rankinglist;
	}

	public long getPoints() {
		return points;
	}

	public void setPoints(long points) {
		this.points = points;
	}

	public String getRankingTrend() {
		return rankingTrend;
	}

	@Override
	public String toString() {
		return "Ranking [id=" + id + ", player=" + player + ", playerKey=" + playerKey + ", points=" + points
				+ ", rank=" + rank + ", rankingTrend=" + rankingTrend + ", rankinglist=" + rankinglist + "]";
	}

}
